package com.wealth.scsj.b_app.adapter;

import android.content.Context;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.wealth.scsj.b_app.R;
import com.wealth.scsj.b_app.bean.DistributionInformationBean;

import java.util.List;

/**
 * 配送信息列表
 */
public class DistributionInformationAdapter extends RecyclerView.Adapter<DistributionInformationAdapter.MyViewHolder> {

    private Context mContext;
    private List<DistributionInformationBean> mList;
    private LayoutInflater mInflater;
    InformationShopAdapter mAdapter;

    public DistributionInformationAdapter(Context context, List<DistributionInformationBean> data) {
        this.mContext = context;
        this.mList = data;
        mInflater = LayoutInflater.from(context);
    }

    @Override
    public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = mInflater.inflate(R.layout.item_distribution_information, parent, false);
        MyViewHolder viewHolder = new MyViewHolder(view);
        return viewHolder;
    }

    @Override
    public void onBindViewHolder(MyViewHolder holder, final int position) {
        holder.mConfigNameTv.setText(mList.get(position).getConfig_name());
        mAdapter =new InformationShopAdapter(mContext,mList.get(position).getInformationBeanList());

        holder.mInformationRv.setLayoutManager(new LinearLayoutManager(
                mContext,LinearLayoutManager.VERTICAL,false));
        holder.mInformationRv.setAdapter(mAdapter);
    }

    @Override
    public int getItemCount() {
        return mList.size();
    }

    public class MyViewHolder extends RecyclerView.ViewHolder {

        public RecyclerView mInformationRv;
        public TextView mConfigNameTv;

        public MyViewHolder(View itemView) {
            super(itemView);
            mInformationRv =  itemView.findViewById(R.id.information_rv);
            mConfigNameTv =  itemView.findViewById(R.id.config_name_tv);
        }
    }

}
